//- Copyright (c) 2016 Lucky Byte, Inc.
extends ../table

block form_items
  .field.two.wide
    select.ui.dropdown.input.role(name="role")
      option(value=" ") 菜单权限
      each k in roles
        if k.uuid == role
          option(value="#{k.uuid}" selected="selected") #{k.name}
        else
          option(value="#{k.uuid}") #{k.name}

  .field.two.wide
    select.ui.dropdown.input.dept(name="dept")
      option(value=" ") 所有部门
      - for (var k in constant.unit_depts)
        if k == dept
          option(value="#{k}" selected="selected")= constant.unit_depts[k]
        else
          option(value="#{k}")= constant.unit_depts[k]

  .field.nine.wide
    if page_perms.new
      button#new.ui.right.floated.green.button(type="button"
        onclick="window.location = '/users/new'") 新增用户
    else
      button#new.ui.right.floated.green.icon.button.disabled(type="button")
        i.icon.ban(style="margin-top:1px; margin-right:2px;")
        | 新增用户

block thead
  tr
    th.center.aligned
    th.center.aligned 序 号
    th.center.aligned 姓 名
    th.center.aligned 登录名
    th.center.aligned 菜单权限
    th.center.aligned 性 别
    th.center.aligned 生 日
    th.center.aligned 所属部门
    th.center.aligned 联系电话
    th.center.aligned 电子邮箱
    th.center.aligned 创建时间
    th.center.aligned 备 注

block tbody
  each record, index in records
    - var td_class = record.disabled ? 'disabled' : ''

    tr(class="#{record.role_root ? 'positive' : ''}")
      td.center.aligned.collapsing
        if record.disabled
          i.icon.lock.orange(
            style="margin-right:0px;" data-content="该用户已被禁用")
        else if record.role_root
          i.icon.user.green(style="margin-right:0px;")
      td.center.aligned.collapsing
        if page_perms.edit || page_perms.disable
          a(href="/users/edit/#{record.serial}")= record.serial
        else
          = record.serial
      td.center.aligned.collapsing(class="#{td_class}")= record.realname
      td.center.aligned.collapsing(class="#{td_class}")= record.loginname
      td.center.aligned.collapsing
        a(href="/roles/edit/#{record.role}")= record.role_name
      td.center.aligned.collapsing(class="#{td_class}")
        = record.gender ? '男' : '女'
      td.center.aligned.collapsing(class="#{td_class}")
        = record.birthday.format('YYYY-MM-DD')
      td.center.aligned.collapsing(class="#{td_class}")
        = constant.unit_depts[record.dept]
      td.center.aligned.collapsing(class="#{td_class}")= record.mobile
      td.center.aligned.collapsing(class="#{td_class}")= record.email
      td.center.aligned.collapsing(class="#{td_class}")
        = record.ctime.format('YYYY-MM-DD HH:mm:ss')
      td(class="#{td_class}")= record.notes
